#pragma once
#include "ScoreSystem.h"

bool bGetDelay(const int delay, int & prevTime, bool bResetPrevTime = true);

ScoreBoard::ScoreBoard(void)
{
	Background = Object2D(800,600);
	Background.setPosition(400,300);
	Continue = Object2D(642,65);
	Continue.setPosition(400,500);
	P1Score_Tenth = P2Score_Tenth = Object2D(100,100);
	P1Score_One = P2Score_One = Object2D(100,100);
	P1Score_Word = P2Score_Word = Object2D(170, 70);
	P1Score_Tenth.setPosition(165,300);
	P1Score_One.setPosition(235,300);
	P2Score_Tenth.setPosition(565,300);
	P2Score_One.setPosition(635,300);
	P1Score_Word.setPosition(200,200);
	P2Score_Word.setPosition(600,200);

	ScenePrevTime = 0;
}

ScoreBoard::~ScoreBoard(void)
{
}

void ScoreBoard::draw()
{
	int P1Score = LeaderBoard::getInstance().P1_GetScore();
	int P2Score = LeaderBoard::getInstance().P2_GetScore();

	Background.drawPlane(Image_Background[0].texID);
	Continue.drawPlane(Image_Background[1].texID);

	P1Score_Tenth.drawPlane(Numbers[0],P1Score/10);
	P1Score_One.drawPlane(Numbers[0],P1Score%10);
	P2Score_Tenth.drawPlane(Numbers[0],P2Score/10);
	P2Score_One.drawPlane(Numbers[0],P1Score%10);

	P1Score_Word.drawPlane(ScoreWord[0].texID);
	P2Score_Word.drawPlane(ScoreWord[1].texID);
}

void ScoreBoard::update()
{
}

void ScoreBoard::reset()
{
}

void ScoreBoard::freeResource()
{
}

void ScoreBoard::loadResource()
{	
	LoadTGA( &Image_Background[0], "images/scorepage/Image_Background.tga", false);
	LoadTGA( &Image_Background[1], "images/scorepage/Image_Continue.tga", false);
	LoadTGA( &ScoreWord[0], "images/catchthegarbage/Image_P1Score.tga", false);
	LoadTGA( &ScoreWord[1], "images/catchthegarbage/Image_P2Score.tga", false);
	Numbers[0] = new Sprite(10,1,"images/catchthegarbage/Image_Numbers.tga");
}

void ScoreBoard::handleKeyboard(int key, int x, int y)
{
	switch(key)
	{
	case 27: glutLeaveMainLoop(); 
	//	SceneManager::getInstance().changeScene("Pause");
		break;
	default: break;
	}
}

void ScoreBoard::handleKeyboardUp(int key, int x, int y)
{
	switch(key)
	{
	case ' ':
		SceneManager::getInstance().changeScene("Stage_Info");
		break;
	}
}

void ScoreBoard::handleKeyboardSpecial(int key, int x, int y)
{
}

void ScoreBoard::getMid(int &x, int &y)
{
}

void ScoreBoard::handleMouseClick(int button, int state, int x, int y)
{
}

void ScoreBoard::handleMouseMove(int x, int y)
{
}